from typing_extensions import Annotated, TypedDict

class NewsSummary(TypedDict):
    """新闻摘要信息"""
    title: Annotated[str, ..., "新闻标题"]
    summary: Annotated[str, ..., "新闻摘要内容"]
    keywords: Annotated[list[str], ..., "新闻关键词"]

from langchain_ollama import ChatOllama
llm = ChatOllama(model="qwen3:8b", temperature=0.5, reasoning=False)
structured_llm = llm.with_structured_output(NewsSummary)

print("流式输出示例:")
for chunk in structured_llm.stream("总结今天的科技新闻"):
    print(chunk)